home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Development Tools & Languages / AEGestalt / About.cp next >
Encoding:
Text File  |  1995-02-12  |  2.9 KB  |  110 lines  |  [TEXT/MPS ]

  1. //     About.cp
  2. //     Copyright © 1992 by Apple Computer, Inc. All rights reserved.
  3. //    Kent Sandvik DTS
  4. //    This file contains the About box code including any adorners/behaviors
  5. //    The resources are placed in the project .r file
  6. //    Version Info (latest first):
  7. //
  8. //    <1>        khs        1.0        First final version
  9.  
  10.  
  11. #ifndef __ABOUT__
  12. #include "About.h"
  13. #endif
  14.  
  15.  
  16. //    Functions
  17.  
  18. #pragma segment ARes
  19. void CreateAboutBox()
  20. {
  21.     TWindow * aboutBoxWindow;
  22.     CStr255 programName,  versionInfo, finalProduct;
  23.  
  24.     //    Yes, I do know this is a waste of resources to 'macroDontDeadStrip' and
  25.     //    register the adorner type every time we open the About box. However, for the
  26.     //    sake of modularity, where I only need to place a CreateAboutBox() statement
  27.     //    inside the TApplication->DoAboutBox(), it made sense - instead of writing all
  28.     //    kinds of init methods that need to be called from IApplication.
  29.  
  30.     macroDontDeadStrip(TMetalBlueFill);
  31.  
  32.     RegisterStdType("TMetalBlueFill", kBlueMetalLook);// register adorner types
  33.  
  34.     //    Get application name    
  35.     gApplication->GetApplicationName(programName);
  36.  
  37.     //    Get version information
  38.     VersRecHndl versInfo = (VersRecHndl)GetResource(kVersInfoType, kVers1InfoID);
  39.     if (versInfo)                                // short one?
  40.         versionInfo = (**versInfo).shortVersion;// get version info from version 1
  41.     else
  42.         versionInfo = " ";                        // nooooothing
  43.  
  44.  
  45.     //    Create Window
  46.     aboutBoxWindow = gViewServer->NewTemplateWindow(phAboutBox, NULL);
  47.     FailNIL(aboutBoxWindow);
  48.  
  49.     //    Hook in any adorners
  50.     aboutBoxWindow->AddAdorner(NewStdAdorner('blmt', "", 'blmt', kFreeOnDeletion), kAdornBefore, kRedraw);
  51.  
  52.     // Stuff in the version info to the other status view, but first get a ptr to it...
  53.     TStaticText * versionField = (TStaticText *)aboutBoxWindow->FindSubView('sta2');
  54.     finalProduct = programName + CStr255(" ") + versionInfo;
  55.     versionField->SetText(finalProduct, TRUE);
  56.  
  57.     //    Open the About box window, and let the user close it whenever...
  58.     aboutBoxWindow->Open();
  59. }
  60.  
  61.  
  62. //    About Box color adorner
  63.  
  64. CRGBColor gMetalBlue(26312,
  65.                      14340,
  66.                      47359);                    // Setup the metal-blue color
  67.  
  68.  
  69. //    Empty constructor - for avoiding ptabs in global data space
  70.  
  71. #undef Inherited
  72. #define Inherited TAdorner
  73.  
  74. #pragma segment ARes
  75. DefineClass(TMetalBlueFill, TAdorner);
  76.  
  77. TMetalBlueFill::TMetalBlueFill()
  78. {
  79. }
  80.  
  81.  
  82. //    Draw TGrayFill Adorner method
  83.  
  84. #pragma segment ARes
  85. void TMetalBlueFill::Draw(TView* itsView,
  86.                                  const VRect&    /*area*/)
  87. {
  88.     CRGBColor saveColor;
  89.     PenState savePenState;
  90.     VRect adornArea;
  91.     CRect QDArea;
  92.     CRect tempRect;
  93.  
  94.     GetPenState(&savePenState);                    // save off the current pen state 
  95.     GetIfColor(saveColor);                        // and the foreground color
  96.     PenNormal();
  97.  
  98.     itsView->GetAdornExtent(adornArea);            // get area
  99.     itsView->ViewToQDRect(adornArea, QDArea);
  100.     tempRect = QDArea;
  101.  
  102.     SetIfColor(gMetalBlue);                        // colorize it
  103.     PaintRect(tempRect);
  104.  
  105.     SetIfColor(saveColor);                        // restore the foreground color and the pen
  106.     SetPenState(&savePenState);
  107. }
  108.  
  109.  
  110.